#pragma once

#include <functional>
#include <condition_variable>
#include <mutex>

class AT {
public:
    using SendDelegate = std::function<void(const char*,size_t)>;
    explicit AT(SendDelegate delegate);

    std::string cmd(const char* cmd, uint32_t waitMs = 300);
    std::string raw(std::string cmd, uint32_t waitMs = 300);

    void onData(std::string data);

private:
    void delayMs(uint32_t ms);

private:
    SendDelegate _sendDelegate;

    std::mutex _mutex;
    std::condition_variable _cond;

    std::string _buf;
};
